package com.fulu.game.bigdata.realtime.config

import java.io.InputStream
import java.util.Properties


class Config {

  val props = load()

  def load(): Properties = {
    val props = new Properties()
    var inputStream: InputStream = null
    try {
      inputStream = Config.getClass.getClassLoader.getResourceAsStream("config.properties")

      props.load(inputStream)

    } catch {
      case e: Exception => new RuntimeException("load config error")
    } finally {
      if (inputStream != null) {
        inputStream.close()
      }
    }
    props
  }

  def get(key: String): String = {
    props.getProperty(key)
  }

  def get(key: String, defaultValue: String): String = {
    props.getProperty(key, defaultValue)
  }

}

object Config {

  private val conf: Config = new Config()

  def getKafkaServer() : String = {
    conf.get("bootstrap.servers")
  }

  def getMySqlSinkUrl() : String = {
    conf.get("mysql_sink_url")
  }

  def getMySqlSinkUsername() : String = {
    conf.get("mysql_sink_username")
  }
  def getMySqlSinkPassword() : String = {
    conf.get("mysql_sink_password")
  }
}
